﻿<xsl:stylesheet version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
	<xsl:output method="html" indent="no"/>
	<xsl:decimal-format NaN=""/>
	<xsl:param name="FileName" />
	<xsl:param name="dvt_apos">'</xsl:param>

	<xsl:template match="/">
		<xsl:call-template name="dvt_1"/>
	</xsl:template>

	<xsl:template name="dvt_1">
		<!-- <div class="heading">
			<xsl:call-template name="dvt_1.heading"/>
		</div> -->

		<xsl:call-template name="dvt_1.body">
			<xsl:with-param name="RssItems" select="/WebcodaRssRotator/rss/channel/item"/>
		</xsl:call-template>
	</xsl:template>

	<xsl:template name="dvt_1.heading">
		<xsl:variable name="channel" select="/WebcodaRssRotator/rss/channel"/>

		<div class="headingTitle">
			<a href="{$channel/link}" title="{$channel/title}">
				<xsl:value-of select="$channel/title" />
			</a>
		</div>
		<div class="headingDescription">
			<xsl:value-of select="$channel/description"/>
		</div>

	</xsl:template>

	<xsl:template name="dvt_1.body">
		<xsl:variable name="RssItems" select="/WebcodaRssRotator/rss/channel/item"/>
		<xsl:variable name="DisplayItems" select="/WebcodaRssRotator/NoItemsDisplay"/>

		<xsl:for-each select="$RssItems">

			<xsl:if test="position() mod $DisplayItems = 1 or ($DisplayItems = 1 and position() mod $DisplayItems = 0)">
				<div class="WebcodaRssRotatorGroup">
					<!--<xsl:attribute name="class">
						<xsl:value-of select="/WebcodaRssRotator/ItemCssClass"/>
					</xsl:attribute>-->

					<xsl:call-template name="dvt_1.rowview">
						<xsl:with-param name="DisplayItems" select="$DisplayItems"/>
						<xsl:with-param name="origPosition" select="position()"/>
					</xsl:call-template>

				</div>
			</xsl:if>

		</xsl:for-each>

	</xsl:template>
	<xsl:template name="dvt_1.rowview">
		<xsl:param name="DisplayItems"/>
		<xsl:param name="origPosition"/>
		<xsl:variable name="items" select="/WebcodaRssRotator/rss/channel/item[position() &gt;= $origPosition and position() &lt; $origPosition + $DisplayItems]"/>

		<xsl:for-each select="$items">
			<xsl:call-template name="dvt_1.rowviewDetail">
				<!--<xsl:with-param name="item" select="$items"/>-->
			</xsl:call-template>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="dvt_1.rowviewDetail">

		<!--<xsl:param name="item"/>-->
		<div class="WebcodaRssRotatorItem">

			<div class="title">
				<xsl:if test="/WebcodaRssRotator/DisplayHeaderLink='true' and /WebcodaRssRotator/LinkInNewWindow = 'true'">
					<a href="{link}" target="_blank" title="{title}">
						<xsl:value-of select="title"/>
					</a>
				</xsl:if>
				<xsl:if test="/WebcodaRssRotator/DisplayHeaderLink = 'true' and /WebcodaRssRotator/LinkInNewWindow = 'false'">
					<a href="{link}" title="{title}">
						<xsl:value-of select="title"/>
					</a>
				</xsl:if>
				<xsl:if test="/WebcodaRssRotator/DisplayHeaderLink = 'false'">
					<xsl:value-of select="title"/>
				</xsl:if>
			</div>

			<hr class="lineUnderTitle"/>

			<xsl:if test="/WebcodaRssRotator/DisplayDate = 'true'">
				<div class="pubDateAndAuthor">
					<xsl:value-of select="pubDate"/> | <xsl:value-of select="author"/>
				</div>
			</xsl:if>

			<div class="description">
				<xsl:if test="string-length(description) &gt; /WebcodaRssRotator/DescriptionSize">
					<xsl:variable name="text" select="substring(description, 1, /WebcodaRssRotator/DescriptionSize)"/>
					<xsl:call-template name="strip-tags">
						<xsl:with-param name="text" select="$text"/>
					</xsl:call-template>
					<xsl:text>...</xsl:text>
				</xsl:if>
				<xsl:if test="string-length(description) &lt;= /WebcodaRssRotator/DescriptionSize">
					<xsl:call-template name="strip-tags">
						<xsl:with-param name="text" select="description"/>
					</xsl:call-template>

				</xsl:if>

				<a class="readMore" href="{link}" title="{title}">&gt;&gt; Read More</a>
			</div>
		</div>
		<!--</xsl:if>-->

	</xsl:template>

	<xsl:template name="strip-tags">
		<xsl:param name="text"/>
		<xsl:choose>
			<xsl:when test="contains($text, '&lt;')">
				<xsl:value-of select="substring-before($text, '&lt;')"/>
				<xsl:call-template name="strip-tags">
					<xsl:with-param name="text" select="substring-after($text, '&gt;')"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$text"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

</xsl:stylesheet>